<?php


namespace app\shop\service\user;


use app\shop\model\user\CollectImgModel;
use app\shop\service\BaseService;
use app\shop\service\until\FileService;

class UserCollectService extends BaseService
{

    public static function getInstance()
    {
        // TODO: Implement getInstance() method.
    }

    public function __construct()
    {
        $this->model = new CollectImgModel();
    }

    /**
     * 收藏图片
     * @param int $userId
     * @param int $fileId
     * @return bool
     * @throws \Exception
     */
    public function collectImg(int $userId, int $fileId): bool
    {
        try {
            $info = $this->getOneLineByWhere(['user_id' => $userId, 'file_id' => $fileId]);
            if ($info) {
                return true;
            }
            $this->saveData(['user_id' => $userId, 'file_id' => $fileId]);
            return true;
        } catch (\Exception $exception) {
            throw new \Exception($exception->getMessage());
        }
    }
}